<template>
	<div id="root" class="root" @click="lastClick">
		<router-view :vue-wechat-title="$route.meta.title"></router-view>
	</div>
</template>

<script>
	export default{
		name:'root',
		data(){
			return{
				isRouterAlive:true,
				lastClickTime:new Date().getTime(),
				currentTime:new Date().getTime(),
				timeInterval:3600000
			}
		},
		mounted(){
			window.setInterval(this.countTime, 1000);
		},
		methods:{
			lastClick(){
				this.lastClickTime = new Date().getTime();  //当界面被点击更新点击时间
			},
			countTime(){
				this.currentTime = new Date().getTime();
				if (this.currentTime -this.lastClickTime > this.timeInterval) {
					window.clearInterval(this.countTime, 1000);
					this.$store.commit('SET_USER', null);
                    this.$store.commit('SET_USERINFOMSG', null);
                    this.$router.replace({
                        path: '/login'
                    });
					setTimeout(() =>{
						this.$router.go(0);
					},2000)
				}
			}
		}
	}
</script>

<style>
	.root{width: 100%;height: 100%;}
</style>